package com.sptpc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.sptpc.service.ProductService;
//控制层
@Controller
public class HomeController {
	//不用new创建对象
	@Autowired
	private ProductService ProductService;
	
	//"/"根目录，zh执行方法跳转至home.jsp页面，并返回home
	@RequestMapping(value="/",method=RequestMethod.GET)
	public String home(Model model) {
		//调用服务层
		model.addAttribute("hlist",ProductService.getHotProduct());
		
		model.addAttribute("nlist",ProductService.getNewProduct());
		return "index";
	}
	
	@RequestMapping(value="/product_info",method=RequestMethod.GET)
	public void productInfo(Model model){
		ProductService.getHotProduct();
	}
}
